﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Order;
using OrderWindow.Properties;
using System.Windows.Forms;

namespace OrderWindow
{
    public partial class Form2 : Form
    {
        private Order.Order neworder=new Order.Order();
        public Order.Order NewOrder
        {
            get
            {
                return neworder;
            }
        }
        private OrderDetail neworderdetail=new OrderDetail();
       
        public Form2()
        {
            InitializeComponent();
            orderIDText.DataBindings.Add("Text", neworder, "OrderID");
            customerText.DataBindings.Add("Text", neworder, "CustomerID");
            textBox1.DataBindings.Add("Text", neworderdetail, "OrderdetailID");
            textBox2.DataBindings.Add("Text", neworderdetail, "ProductID");
            textBox3.DataBindings.Add("Text", neworderdetail, "ProductNumber");
            textBox4.DataBindings.Add("Text", neworderdetail, "Value");
            bindingSource1.DataSource = neworder;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //neworderdetail.OrderdetailID =Convert.ToInt32(textBox1.Text);
            //neworderdetail.ProductID = textBox2.Text;
            //neworderdetail.ProductNumber = Convert.ToInt32(textBox3.Text);
            //neworderdetail.Value = Convert.ToInt32(textBox4.Text);
            OrderDetail myclone = new OrderDetail(neworderdetail.OrderdetailID, neworderdetail.ProductID, neworderdetail.ProductNumber, neworderdetail.Value);
            neworder.OrderDetailsList.Add(myclone);
            textBox1.Clear();
            textBox3.Clear();
            textBox4.Clear();
            textBox2.Clear();
            bindingSource1.ResetBindings(false);
        }

        private void button2_Click(object sender, EventArgs e)
        {

            this.Close();
        }
    }
}
